#ifndef SLAVE_TIMER_REQLIST_H_
#define SLAVE_TIMER_REQLIST_H_

#include "../base/conf.h"
#include "slave_timer_protocol.h"

C_CODE_BEGIN

struct slave_timer_reqlist;

struct slave_timer_req_runtime {
	struct slave_timer_req req;
	size_t elapsed_tick;
	char name[NAME_MAX_LEN];
};

/*
 * This reqlist is specifically designed for timer slave, so it is a not general purpose
 * multi-thread list. In fact, this list MUST be used in different thread. Simply puts it
 * the list uses a lazy remove technique, the remove operation will only be happened once 
 * the iteration happens.
 */


struct slave_timer_reqlist* _reqlist_create( size_t size );
void _reqlist_destroy( struct slave_timer_reqlist* );

struct slave_timer_req_runtime* _reqlist_query( struct slave_timer_reqlist* , const char* src );

bool _reqlist_insert( struct slave_timer_reqlist* , struct slave_timer_req_runtime* );
bool _reqlist_remove( struct slave_timer_reqlist* , const char* src );


void* _reqlist_begin_iterator( struct slave_timer_reqlist* );
void* _reqlist_end_iterator( struct slave_timer_reqlist* );
void* _reqlist_move_iterator( struct slave_timer_reqlist* , void* );
struct slave_timer_req_runtime* _reqlist_deref_iterator( void* );


C_CODE_END



#endif //SLAVE_TIMER_REQLIST_H_